{extend name='common/common' /}

{block name="content"}
<el-card class="box-card">
	<div slot="header">
		<span class="span-primary"><i class="el-icon-search"></i></span>
		报表报送情况查询
	</div>
	<div class="formBox">
		<el-form :model="form" :inline="true" ref="seaForm" :rules="rules" label-width="100px">
			<el-form-item>
				<el-select v-model="form.depart_id" placeholder="请选择地区">
					{volist name="departs_opt" id="v"}
					<el-option label="{$v.name}" value="{$v.id}"></el-option>
					{/volist}
				</el-select>
			</el-form-item>
			<el-form-item prop="type">
				<el-select v-model="form.type" @change="changeTimePickerType" placeholder="请选择报表类型">
					<el-option label="日报" value="1"></el-option>
					<el-option label="月报" value="2"></el-option>
					<el-option label="年报" value="3"></el-option>
					<el-option label="固定资产" value="4"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item prop="s_time">
				<el-date-picker
					v-model="form.s_time"
					:type="time_type"
					value-format="timestamp"
					placeholder="开始时间">
				</el-date-picker>
			</el-form-item>
			<el-form-item prop="e_time">
				<el-date-picker
					v-model="form.e_time"
					:type="time_type"
					value-format="timestamp"
					placeholder="结束时间">
				</el-date-picker>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" icon="el-icon-search" plain @click="search">查询</el-button>
			</el-form-item>
		</el-form>
	</div>
	<div class="tableBox">
		<el-table :data="table.tableData" border :empty-text="table.table_empty_text">
			<el-table-column align="center" prop="table_type" label="报表类型"></el-table-column>
			<el-table-column align="center" prop="rpt_date" label="报表日期"></el-table-column>
			<el-table-column align="center" prop="depart_name" label="填表地区"></el-table-column>
			<el-table-column align="center" prop="link_man" label="填表人"></el-table-column>
			<el-table-column align="center" prop="link_type" label="联系方式"></el-table-column>
			<el-table-column align="center" prop="is_commit" label="提交状态">
				<template slot-scope="scope">
					<el-tag
						:type="scope.row.is_commit == '1' ? 'success' : 'danger'">
						{{scope.row.is_commit_name}}
					</el-tag>
	      		</template>
			</el-table-column>
		</el-table>
		<div class="table-page">
			<el-pagination
				@size-change="pageSizeChange"
				@current-change="curPageChange"
				:current-page="table.pageNumber"
				:page-sizes="[10, 20, 50, 75]"
				:page-size="table.pageSize"
				layout="total, sizes, prev, pager, next, jumper"
				:total="table.tableTotal">
			</el-pagination>
		</div>
	</div>
</el-card>
{/block}

{block name="script"}
<script type="text/javascript">
var main = new Vue({
	el:"#main",
	data:{
		loading:false,
		time_type:"date",
		form:{
			depart_id:"{$department.id|default='0'}",
			type:"",s_time:"",e_time:""
		},
		rules:{
			type:[{required:true,message:'请选择报表类型',trigger:['change','blur']}],
			s_time:[{required:true,message:'请选择开始时间',trigger:['change','blur']}],
			e_time:[{required:true,message:'请选择结束时间',trigger:['change','blur']}],
		},
		table:{
			tableData:"",
			table_empty_text:"请选择查询条件",
			pageSize:10,
			pageNumber:1,
			tableTotal:0,
		}
	},
	methods: {
		changeTimePickerType() {
			switch (this.form.type) {
				case '1':
					this.time_type = "date";
					break;
				case '2':
					this.time_type = "month";
					break;
				case '3':
					this.time_type = "year";
					break;
				case '4':
					this.time_type = "month";
					break;
				default:
					this.$notify.error({title:"错误",message:"请选择报表类型"});
					break;
			}
		},
		search() {
			this.$refs['seaForm'].validate((valid) => {
				if(valid){
					this.getTable();
				}else{
					this.$notify.error({title:"错误",message:"查询条件不全"});
				}
			});
		},
		getTable() {
			this.loading=true;
			var param = {
				depart_id:this.form.depart_id,
				type:this.form.type,
				s_time:Number(this.form.s_time)/1000,
				e_time:Number(this.form.e_time)/1000,
				pageSize:this.table.pageSize,
				pageNumber:this.table.pageNumber,
			};
			$.post('./getSendResult',param,function(res){
				main.loading=false;
				if(res.code == 1){
					main.$message({message: res.msg,type: 'success'});
					main.table.tableData = res.data.rows;
					main.table.tableTotal = res.data.total;
				}else if(res.code == -1){
					main.table.tableData = '';
					main.table.tableTotal = 0;
					main.table.table_empty_text = res.msg;
				}else{
					main.$notify.error({title: '失败',message: res.msg});
				}
			});
		},
		pageSizeChange(val) {
			this.table.pageSize = val;
			this.getTable();
		},
		curPageChange(val) {
			this.table.pageNumber = val;
			this.getTable();
		},
	}
});
</script>
{/block}
